/* eslint-disable no-unused-vars */
/**
 * ctp模块菜单设置
 */
var ctpMenuOption = {
  // 首页配置
  home: {
    // 默认激活的一级菜单
    activeName: function () {
      console.log('默认激活一级菜单，校验角色权限')
      var role = 'first'
      var userInfo = ''
      var userInfoObj = {}
      var resources = ''

      var data = sessionStorage
      //console.log(data)
      if (data.length > 0) {
        userInfo = data.userInfo
        if (userInfo != undefined && userInfo.length > 0) {
          userInfoObj = JSON.parse(userInfo)
          //console.log(userInfoObj)
          var content = userInfoObj.content
          resources = content.resources
          if (!resources.includes('first')) {

            if (resources.includes('adjustment')) {
              role = 'adjustment'
            } else if (resources.includes('faceuserinfo')) {
              role = 'faceuserinfo'
            } else if (resources.includes('loanhistory')) {
              role = 'loanhistory'
            } else if (resources.includes('workorder')) {
              role = 'workorder'
            } else if (resources.includes('soundrecording')) {
              role = 'soundrecording'
            }
          }

        }

      }
      console.log(role)
      return role

    },
    // 默认重定向的首页
    //redirectName: "adjustment",
    redirectName: function () {
      console.log('重定向，校验角色权限')
      var role = 'personal'
      var userInfo = ''
      var userInfoObj = {}
      var resources = ''

      var data = sessionStorage
      // console.log(data)
      if (data.length > 0) {
        userInfo = data.userInfo

        if (userInfo != undefined && userInfo.length > 0) {
          userInfoObj = JSON.parse(userInfo)
          console.log(userInfoObj)
          var content = userInfoObj.content
          console.log(content)
          resources = content.resources
          console.log(resources)
          if (!resources.includes('first')) {

            if (resources.includes('adjustment')) {
              role = 'adjustment'
            } else if (resources.includes('faceuserinfo')) {
              role = 'faceuserinfo'
            } else if (resources.includes('loanhistory')) {
              role = 'loanhistory'
            } else if (resources.includes('workorder')) {
              role = 'workorder'
            } else if (resources.includes('soundrecording')) {
              role = 'soundrecording'
            }
          }

        }

      }

      console.log(role)
      return role

    },
    // 菜单配置
    tabs: [
      {
        label: "智能推荐",
        name: "ten",
        show: false,
        main: {
          type: "component",
          id: "",
          src: "",
          defaultActive: ""
        },
        children: []
      },

      {
        label: "贷款业务",
        name: "first",
        show: true,
        main: {
          type: "router-view",
          id: "",
          src: "",
          defaultActive: "/personal"
        },
        children: [
        ]
      },
      {
        label: "调单管理",
        name: "adjustment",
        show: true,
        main: {
          type: "router-view",
          id: "",
          src: "",
          defaultActive: "/adjustment"
        },
        children: []
      },
      {
        label: "面签客户信息",
        name: "faceuserinfo",
        show: true,
        main: {
          type: "router-view",
          id: "",
          src: "",
          defaultActive: "/faceuserinfo"
        },
        children: []
      },
      {
        label: "历史贷款审批记录",
        name: "loanhistory",
        show: true,
        main: {
          type: "router-view",
          id: "",
          src: "",
          defaultActive: "/loanhistory"
        },
        children: []
      },
      //      {
      //        label: "答题模板",
      //        name: "ansyertemp",
      //        show: true,
      //        main: {
      //          type: "router-view",
      //         id: "",
      //          src: "",
      //          defaultActive: "/ansyertemp"
      //        },
      //        children: []
      //      },
      {
        label: "工单历史",
        name: "workorder",
        show: true,
        main: {
          type: "router-view",
          id: "",
          src: "",
          defaultActive: "/workorder"
        },
        children: []
      },
      {
        label: "录音历史",
        name: "soundrecording",
        show: true,
        main: {
          type: "router-view",
          id: "",
          src: "",
          defaultActive: "/soundrecording"
        },
        children: []
      },
      {
        label: "电子工单",
        name: "four",
        show: false,
        main: {
          type: "component"
        },
        children: []
      },
      {
        label: "电子工单",
        name: "five",
        show: true,
        main: {
          type: "iframe",
          id: "ets-create-frame",
          src: function () {
            return window.CONFIG.ets.createIndexPage;
          }
        },
        children: []
      },

      {
        label: "知识库",
        name: "nine",
        show: false,
        main: {
          type: "iframe",
          id: "kbp-frame",
          src: function () {
            return (
              window.CONFIG.kbp.createIndexPage +
              "?access_token=" +
              Constants.Agent.access_token
            );
          }
        },
        children: []
      },

      {
        label: "知识库",
        name: "eleven",
        show: true,
        main: {
          type: "router-view",
          id: "kbpRouter",
          src: "",
          defaultActive: "kbp"
        },
        children: []
      },



      {
        label: "信用卡业务",
        name: "second",
        show: false,
        main: {},
        children: []
      },
      // {
      //   label: '视频业务',
      //   name: 'third',
      //   show: false,
      //   main: {
      //     type: 'router-view',
      //     id: 'videoServices',
      //     src: '',
      //     defaultActive: '/cardActive',
      //     defaultPhoneBankActive: '/phoneBankCardActive'
      //   },
      //   children: [
      //     {
      //       label: '卡激活',
      //       path: '/cardActive',
      //       isHideFlag: false
      //     },
      //     {
      //       label: '不动户恢复',
      //       path: '/realEstateRecovery'
      //     },
      //     {
      //       label: '账户限制解除',
      //       path: '/accRestrictLift'
      //     },
      //     {
      //       label: '对公开户',
      //       path: '/forOpenHouse',
      //       isHideFlag: false
      //     },
      //     {
      //       label: '卡激活',
      //       path: '/phoneBankCardActive',
      //       isHideFlag: true
      //     },
      //     {
      //       label: '对公开户',
      //       path: '/phoneBankForOpenHouse',
      //       isHideFlag: true
      //     },
      //     {
      //       label: '风险测评',
      //       path: '/phoneBankRiskAssessment'
      //     },
      //   ]
      // },

      {
        label: "智能助手",
        name: "six",
        show: false,
        main: {
          type: "iframe",
          id: "intel-assis-frame",
          src: function () {
            return window.CONFIG.intelligentAssisTant.createIndexPage;
          }
        },
        children: []
      },
      {
        label: "网页协同",
        name: "seven",
        show: false,
        main: {},
        children: []
      },
      {
        label: "人脸识别",
        name: "eight",
        show: false,
        main: {
          type: "iframe",
          id: "face-recognition-frame",
          src: function () {
            return window.CONFIG.faceRecognition.createIndexPage;
          }
        },
        children: []
      }

      // {
      //   label: '电核结果通知',
      //   name: 'twelve',
      //   show: true,
      //   main: {
      //     type: 'router-view',
      //     id: 'dhRouter',
      //     src: '',
      //     defaultActive: 'dhResultNotice'
      //   },
      //   children: []
      // },
    ]
  },
  // 路由配置
  router: {}
};
